gnttab: __gnttab_unmap_common_complete() is all-or-nothing
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:46:47 +0000 (14:46 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:46:47 +0000 (14:46 +0200)
commit11fc7ccb7217ccfb79edb727d1349618bcb0602d
tree3201bcf50ce57966c2e166a0c61b59afe368eea1
parent75b384ece635adc55c2bafbdc2d8959c10542c31
gnttab: __gnttab_unmap_common_complete() is all-or-nothing

All failures have to be detected in __gnttab_unmap_common(), the
completion function must not skip part of its processing. In particular
the GNTMAP_device_map related putting of page references and adjustment
of pin count must not occur if __gnttab_unmap_common() signaled an
error. Furthermore the function must not make adjustments to global
state (here: clearing GNTTAB_device_map) before all possibly failing
operations have been performed.

There's one exception for IOMMU related failures: As IOMMU manipulation
occurs after GNTMAP_*_map have been cleared already, the related page
reference and pin count adjustments need to be done nevertheless. A
fundamental requirement for the correctness of this is that
iommu_{,un}map_page() crash any affected DomU in case of failure.

The version check appears to be pointless (or could perhaps be a
BUG_ON() or ASSERT()), but for the moment also move it.

This is part of XSA-224.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/common/grant_table.c
xen/include/asm-arm/grant_table.h
xen/include/asm-x86/grant_table.h